<template>
  <div>
    <h1>{{ $store.state.name }}</h1>
    <button @click="$store.commit('setName', '老李')">修改</button>
  </div>
</template>
<script>
export default {
  mounted() {
    console.log(this.$store);
    console.log(this.$store.state.A);
    console.log(this.$store.state.B);
    // 调用父级的mutations方法
    this.$store.commit("setName", "老张");
    // 调用子级方法
    this.$store.commit("A/setlist", { id: 2, text: "我是新增的" });
  },
};
</script>